package com.bbx.taxi.client.Task;

import java.util.ArrayList;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import android.app.Activity;
import android.os.AsyncTask;

import com.bbx.androidapi.util.ToastUtil;
import com.bbx.api.sdk.model.official.passanger.Offciail_DevaluateBuild;
import com.bbx.api.sdk.model.official.passanger.Officail_VclassBuild;
import com.bbx.api.sdk.model.official.passanger.Offciail_DevaluateBuild;
import com.bbx.api.sdk.model.official.passanger.Return.Officail_Vehicle;
import com.bbx.api.sdk.model.official.passanger.Return.Officail_Vehicle.VehicleList;
import com.bbx.api.sdk.net.base.JsonBuild;
import com.bbx.api.sdk.net.official.passanger.Offciail_DevaluateNet;
import com.bbx.api.sdk.net.official.passanger.Officail_VclassNet;
import com.bbx.api.sdk.net.official.passanger.Officail_VehicleNet;
import com.bbx.api.sdk.net.official.passanger.Official_OperateNet;
import com.bbx.taxi.client.Bean.Value;
import com.bbx.taxi.client.Task.BaseAsyncTask;
import com.bbx.taxi.client.MyApplication;
import com.bbx.taxi.official.R;

/** 
 * @Path com.bbx.taxi.client.Task.MyOrderEvaluateTask.java
 * @Author 严旭文
 * @Date 2016-2-4 下午5:15:04
 * @Company 蓝海（福建）信息技术有限公司
 * @Description
 */
public class MyOrderEvaluateTask {
	public static int STATUS_SUCCESS=0;
	public static int STATUS_FAIL=-1;
	private Activity context;
	public static MyOrderEvaluateTask instance;
	public OrderEvaluateTask mOrderEvaluateTask;
	public interface OnOrderEvaluateListener {
		/**
		 *status 0为成功
		 */
		public void onOrderEvaluate(int status);
	}

	static OnOrderEvaluateListener mOnOrderEvaluateListener = null;

	public static void setOnOrderEvaluateListener(OnOrderEvaluateListener l) {
		mOnOrderEvaluateListener = l;
	}
	public static MyOrderEvaluateTask getInstance(Activity context,Offciail_DevaluateBuild mOffciail_DevaluateBuild) {
		instance = new MyOrderEvaluateTask(context,mOffciail_DevaluateBuild);
		return instance;
	}
	public MyOrderEvaluateTask(Activity context,Offciail_DevaluateBuild mOffciail_DevaluateBuild) {
		this.context = context;
		getOperate(mOffciail_DevaluateBuild);
	}
	/**
	 * 订单评价
	 */
	public void getOperate(Offciail_DevaluateBuild mOffciail_DevaluateBuild) {
		mOrderEvaluateTask = new OrderEvaluateTask(context, mOffciail_DevaluateBuild);
		mOrderEvaluateTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
	}
	private class OrderEvaluateTask extends BaseAsyncTask {

		private Offciail_DevaluateBuild mOffciail_DevaluateBuild;

		public OrderEvaluateTask(Activity context, Offciail_DevaluateBuild mOffciail_DevaluateBuild) {
			super(context);
			this.mOffciail_DevaluateBuild = mOffciail_DevaluateBuild;
		}

		@Override
		public void onSuccess(Object object) {
	
			if (mOnOrderEvaluateListener != null) {
				mOnOrderEvaluateListener.onOrderEvaluate(STATUS_SUCCESS);
			}
		}

		@Override
		public void onFailed(int status, String msg) {
			ToastUtil.showToast(context, R.string.no_network);
			if (mOnOrderEvaluateListener != null) {
				mOnOrderEvaluateListener.onOrderEvaluate(STATUS_FAIL);
			}
		}

		@Override
		protected Object doInBackground(Object... params) {
			// TODO Auto-generated method stub
			String json = new JsonBuild().setModel(mOffciail_DevaluateBuild).getJson();
			return new Offciail_DevaluateNet(context, json);
		}
	}

}
